﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;

namespace Web_Demo
{
    public partial class Right_Click : System.Web.UI.Page
    {
        protected void Page_Load(object sender, EventArgs e)
        {            
            ContextMenu2.BoundControls.Add(TreeView1);
        }
        protected void ContextMenu1_ItemCommand(object sender, CommandEventArgs e)
        {
            switch (e.CommandName)
            {
                case "Add":
                    //Response.Write(TreeView1.SelectedNode.Value.ToString());
                    TreeNode tnNode = new TreeNode();
                    tnNode.Text = TreeView1.SelectedNode.Value.ToString()+"1";
                    tnNode.Value = TreeView1.SelectedNode.Value;
                    tnNode.Expanded = true;                   
                    TreeView1.FindNode(TreeView1.SelectedNode.ValuePath).ChildNodes.Add(tnNode);  
                    break;

                case "Delete":
                    //TreeView1.Nodes.Remove(TreeView1.SelectedNode);
                    TreeView1.Nodes.Remove(TreeView1.SelectedNode);
                    break;

                default:
                    Response.Write("Oke!!!");
                    break;
            }
        }

    }
}